<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
</head>

<body>
    <header class="aui-bar aui-bar-nav" style="background-color: #03a9f4;position:fixed;" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            不合格品库转
        </div>
    </header>
    <div class="aui-content aui-margin-b-15" style="margin-top:60px;">
        <ul class="aui-list aui-form-list">
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label" style="padding-right: 100px;">条码</div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="请扫描条码" id="boxnum" value="" onclick="getIdSelector();">
                    </div>
                </div>
            </li>
            <li class="aui-list-item" style="display:none">
                <div class="aui-list-item-inner" >
                    <div class="aui-list-item-label" style="padding-right: 100px;">条码</div>
                    <div class="aui-list-item-input">
                        <input type="text"  id="tm" value="" onclick="getIdSelector();">
                    </div>
                </div>
            </li>
            <li class="aui-list-item" style="display:none">
                <div class="aui-list-item-inner" >
                    <div class="aui-list-item-label" style="padding-right: 100px;">缺陷类型编码</div>
                    <div class="aui-list-item-input">
                        <input type="text"  id="qxTypeCode" value="" onclick="getIdSelector();">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label" style="padding-right: 100px;">缺陷类型</div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="选择 缺陷类型" id="qxTypeName" value=""
                             />
                    </div>
                    <i class="aui-input-addon aui-iconfont aui-icon-right" onclick="getqxTypeCode()"></i>
                    
                </div>
            </li>
            <li class="aui-list-item" style="display:none">
                <div class="aui-list-item-inner" >
                    <div class="aui-list-item-label" style="padding-right: 100px;">缺陷原因编码</div>
                    <div class="aui-list-item-input">
                        <input type="text"  id="mrlAttribute4" value="" onclick="getIdSelector();">
                    </div>
                </div>
            </li>

            
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label" style="padding-right: 100px;">缺陷原因</div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="选择 缺陷原因" id="mrlAttribute5" value=""
                             />
                    </div>
                    <i class="aui-input-addon aui-iconfont aui-icon-right" onclick="getqxTypeName()"></i>
                    
                </div>
            </li>

           
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label" style="padding-right: 100px;">源仓库</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="workCenterCode" disabled="true">
                    </div>
                </div>
            </li>
            
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label" style="padding-right: 100px;">源库位</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="workCellCode" disabled="true">
                    </div>
                </div>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label" style="padding-right: 100px;">目标仓库</div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="选择/扫描 调入库位" id="relWorkCenterCode" value=""
                            onclick="getIdSelector();" />
                    </div>
                    <i class="aui-input-addon aui-iconfont aui-icon-right" onclick="goSelectWorkCenter()"></i>
                </div>
            </li>
            
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label" style="padding-right: 100px;">调入库位</div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="选择/扫描 调入库位" id="relWorkCellCode" value=""
                            onclick="getIdSelector();" />
                    </div>
                    <i class="aui-input-addon aui-iconfont aui-icon-right" onclick="goSelectWorkCell()"></i>
                </div>
            </li>
            

        </ul>
        <p></p>
        <p></p>
        <div class="aui-btn aui-btn-info aui-btn-block" onclick="save()">库转</div>
        
        <footer class="aui-bar aui-bar-tab" id="footer">
            <div class="aui-bar-tab-item" tapmode id="scan" onclick="doScan()">
                <i class="aui-iconfont aui-icon-scan aui-text-epblue" style="font-size: 1.8rem"></i>
            </div>
        </footer>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript">
    //光标所在id
    var idSelector = "";
    var relWorkCenterGid = ""; //目标仓库GID
    var relWorkCenterCode = ""; //目标仓库编码
    var relWorkCenterName = ""; //目标仓库名称
    var relWorkCellGid = ""; //调入库位GID
    var relWorkCellCode = ""; //调入库位编码
    var relWorkCellName = ""; //调入库位名称
    var workCellGid = ""; //调出库位GID
    var workCellCode = ""; //调出库位编码
    var workCellName = ""; //调出库位名称
    var workCenterGid = ""; //调出库位GID
    var workCenterCode = ""; //调出库位编码
    var qxTypeId="";
    var qxTypeCode = "";
    var qxTypeName = "";
    var workCenterName = ""; //调出库位名称
    var qxNameId="";
    var mrlAttribute4 = "";
    var mrlAttribute5 = "";

    var scanRule = ""; //条码解析规则


    //初始化查询仓库下拉框
    apiready = function () {

        $("#boxnum").focus();
        idSelector = "boxnum";
        //查询条码解析规则
        initScanRule();
    }

    // 获取光标所在组件的id
    function getIdSelector() {
        var e = event || window.event;
        var el = e.srcElement || e.target;
        idSelector = el.id;
        $("#" + el.id).select();
    }

    //扫描
    function doScan() {
        var moduleScanner = api.require('moduleScanner');
        var params = {
            top: 150, //扫描窗口的上边距
            width: 250, //扫描窗口的宽
            height: 250, //扫描窗口的高
            useColor: false, //是否使用自己设定的颜色(startColor和endColor),
            //如果不使用设定的颜色就使用默认的那张网格图
            startColor: '#0F08C8FF', //渐变起始颜色
            endColor: '#7F08C8FF', //渐变结束颜色
            animTime: 2200, //扫描动画时间,单位为毫秒
        };
        moduleScanner.toScannerActivityForResult(params, function (ret, err) {

            if (idSelector == 'relWorkCellCode') {

                $("#relWorkCellCode").val(ret);
                //查询调入库位
                getWorkCell(ret, idSelector, "2");

                //5：扫描条码
            } else if (idSelector == 'boxnum') {
                tmSplit1(ret);
            } else if (idSelector == 'relWorkCenterCode') {
                $("#relWorkCenterCode").val(ret);
                //查询调入库位
                getWorkCenter(ret, idSelector, "2");
            }
        });
    }

    //查询扫描规则
    function initScanRule() {
        var serverUrl = localStorage.getItem('serverUrl');
        var un = localStorage.getItem("un");
        var url = serverUrl + "/app/getTmScanRule";
        var data = {
            values: {
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                if (myobj.code == '0') {
                    scanRule = myobj.scanRule
                    console.log("scanRule:" + scanRule);
                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
    }
    //仓库扫描校验
    function getWorkCenter(code, inputId) {
        var serverUrl = localStorage.getItem('serverUrl');
        var un = localStorage.getItem('un');
        var url = serverUrl + "/app/getWorkCenter";
        var data = {
            values: {
                workCenterCode: code,
                un:un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                if (myobj.code == '0') {
                    var list = eval(myobj.list);
                    relWorkCenterGid=list[0].workCenterGid;

                    relWorkCenterCode = list[0].workCenterCode;
                    relWorkCenterName = list[0].workCenterName;
                    document.getElementById(inputId).value = relWorkCenterCode+":"+relWorkCenterName;
                    $("#relWorkCenterCode").focus();
                    idSelector = "relWorkCenterCode";

                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                    $("#relWorkCenterCode").focus();
                    $("#relWorkCenterCode").select();
                }
            }
        });
    }

    //选择仓库
    function goSelectWorkCenter() {
        api.openWin({
            name: 'uwmSelectWorkCenter',
            url: 'uwmSelectWorkCenter.html',
            pageParam: {
                flag: "in",
                name: "uwmStockBhg",
                mrlCode: "",
                lotCode: "",
                qty: ""
            }
        });
    }
     function getqxTypeCode() {
        api.openWin({
            name: 'uwmSelectQxType',
            url: 'uwmSelectQxType.html',
            pageParam: {
                name: "uwmStockBhg",
            }
        });
    }
    function setqxTypeName(id, code, name) {
        qxNameId=id;
        $("#mrlAttribute4").val(code) ;
        mrlAttribute5 = name;
        document.getElementById('mrlAttribute5').value = code +":"+name;
        $("#mrlAttribute5").focus();
        idSelector = "mrlAttribute5";
    }
    function getqxTypeName() {
        api.openWin({
            name: 'uwmSelectQxName',
            url: 'uwmSelectQxName.html',
            pageParam: {
                name: "uwmStockBhg",
                qxTypeId:qxTypeId,
            }
        });
    }
    function setqxTypeCode(id, code, name) {
        qxTypeId=id;
        $("#qxTypeCode").val(code) ;
        qxTypeName = name;
        document.getElementById('qxTypeName').value = code+ ":"+name;
        $("#qxTypeName").focus();
        idSelector = "qxTypeName";
    }

    //仓库选择后回调函数
    function setWorkCenter(id, code, name) {
        relWorkCenterGid=id;
        relWorkCenterCode = code;
        relWorkCenterName = name;
        //$("#workCenterCode").attr("value",code+":"+name);
        document.getElementById('relWorkCenterCode').value = code+":"+name;
        $("#relWorkCenterCode").focus();
        idSelector = "relWorkCenterCode";
    }


    //库位扫描校验
    function getWorkCell(code, inputId, flag) {
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getWorkCell";
        var params = new Object();
        params.url = url;
        params.dataType = 'json';
        params.method = 'post';
        var data = {
            values: { ////以表单方式提交参数（JSON对象）
                relWorkCellCode: code, //库位编码
                flag: "search",
                un: un,
                workCenterGid: relWorkCenterGid,
                relWorkCellGid: "",
                workCellFlag: '2'
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                if (myobj.code == '0') {
                    var list = myobj.list;

                    //源库位
                    if (flag == "1") {

                        workCellGid = list[0].workCellGid;
                        workCellCode = list[0].workCellCode+":"+list[0].workCellName;
                        workCellName = list[0].workCellName;
                        document.getElementById(inputId).value = workCellCode;
                        $("#boxnum").focus();
                        idSelector = "boxnum";


                        //调入库位
                    } else if (flag == "2") {
                        relWorkCellGid = list[0].workCellGid;
                        relWorkCellCode = list[0].workCellCode;
                        relWorkCellName = list[0].workCellName;
                        document.getElementById(inputId).value = relWorkCellCode+":"+relWorkCellName;
                        $("#relWorkCellCode").focus();
                        idSelector = "relWorkCellCode";
                    }
                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                    $("#" + inputId).focus();
                    $("#" + inputId).select();
                }
            }
        });
    }
    //选择库位
    function goSelectWorkCell() {
        var tm = $("#tm").val();
        //仓库非空校验
        if (relWorkCenterGid == "" || relWorkCenterGid == null || relWorkCenterGid == undefined) {
            api.toast({
                msg: "请先选择/扫描 目标仓库",
                duration: 3000
            });
            return;
        }

        api.openWin({
            name: 'uwmSelectWorkCell',
            url: 'uwmSelectWorkCell.html',
            pageParam: {
                flag: "search",
                name: "uwmStockBhg",
                tm: tm,
                workCenterGid: relWorkCenterGid,
                relWorkCellGid: "",
                workCellFlag: '2'
            }
        });
    }

   

    //库位选择后回调函数
    function setWorkCell(id, code, name) {
        console.log("1223123库位选择后回调");
            relWorkCellGid = id;
            relWorkCellCode = code;
            relWorkCellName = name;
            document.getElementById('relWorkCellCode').value = code+":"+name;

         
    }

  
    //PDA自带扫描回车事件
    $("#relWorkCenterCode").on('keypress', function (e) { //#keyword为input文本框
        var keycode = e.keyCode;
        var sm = $(this).val();
        if (keycode == '13') {

            //仓库编码
            $("#relWorkCenterCode").val(sm);
            getWorkCenter(sm, "relWorkCenterCode");
        }
    });

    //PDA自带扫描回车事件-调入库位
    $("#relWorkCellCode").on('keypress', function (e) { //#keyword为input文本框
        var keycode = e.keyCode;
        var sm = $(this).val();
        if (keycode == '13') {

            $("#relWorkCellCode").val(sm);
            getWorkCell(sm, "relWorkCellCode", "2");
        }
    });

    //库转按钮
    function save() {
        //缺陷类型编码
        var qxTypeCode = $("#qxTypeCode").val();
        //缺陷类型名称
        var qxTypeName = $("#qxTypeName").val();
        //缺陷原因编码
        var mrlAttribute4 = $("#mrlAttribute4").val();
        //条码
        var tm = $("#tm").val();
        //条码唯一号ID
        var tmId = $("#tmId").val();
        //缺陷原因名称
        var mrlAttribute5 = $("#mrlAttribute5").val();
        
        //箱号
        var boxnum = $("#boxnum").val();
        
        


        //调入库位非空校验
        if (relWorkCellCode == "" || relWorkCellCode == null || relWorkCellCode == undefined) {
            api.toast({
                msg: '请选择/扫描 调入库位',
                duration: 3000
            });
            return;
        }

        //缺陷类型非空校验
        if (qxTypeName == "" || qxTypeName == null || qxTypeName == undefined) {
            api.toast({
                msg: '缺陷类型不能为空',
                duration: 3000
            });
            return;
        }
        //缺陷原因非空校验
        if (mrlAttribute5 == "" || mrlAttribute5 == null || mrlAttribute5 == undefined) {
            api.toast({
                msg: '缺陷原因不能为空',
                duration: 3000
            });
            return;
        }


        api.showProgress({
            title: '保存中...',
        });
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/uwmStockBhg";
        var params = new Object();
        params.url = url;
        params.dataType = 'json';
        params.method = 'post';
        var data = {
            values: { ////以表单方式提交参数（JSON对象）
                relWorkCellCode: relWorkCellCode, // 调入库位
                relWorkCenterCode: relWorkCenterCode, //目标仓库编码
                relWorkCenterGid:relWorkCenterGid,//目标仓库id
                relWorkCellGid:relWorkCellGid,//调入库位id
                workCenterGid:workCenterGid,//源仓库id
                workCellGid:workCellGid,//源库位id
                qxTypeCode: qxTypeCode, //缺陷类型编码
                qxTypeName: qxTypeName, //缺陷类型名称
                mrlAttribute5: mrlAttribute5, //缺陷原因名称
                tm: tm, //条码
                boxnum:boxnum,
                mrlAttribute4: mrlAttribute4, //缺陷原因编码
                tmId: tmId, //条码唯一号ID
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {

                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //成功
                if (myobj.code == '0') {

                    api.hideProgress();

                    api.toast({
                        msg: "保存成功",
                        duration: 3000
                    }); //清空表单
                    $("#tm").val("");
                    $("#boxnum").val("");
                    $("#qxTypeName").val("");
                    $("#workCenterCode").val("");
                    $("#workCellCode").val("");
                    $("#mrlAttribute5").val("");
                    workCellGid = "";
                    workCellCode = "";
                    workCellName = "";
                    var map = eval("(" + myobj.msg + ")");;

                    for (var key in map) {
                        console.log("key:" + key);
                        $("#" + key).html(map[key]);
                    }
                    console.log("777777");
                    $("#tableDiv").css('display', 'block');

                    $("#boxnum").focus();
                    idSelector = "boxnum";
                    console.log("888888");


                } else {
                    api.hideProgress();
                    $("#boxnum").val("");
                    $("#tm").val("");
                    
                    api.toast({
                        msg: myobj.msg,
                        duration: 3000
                    });
                    $("#tm").focus();
                    $("#boxnum").focus();
                    idSelector = "boxnum";
                }
            }else{
                $("#boxnum").val("");
                $("#boxnum").select();
                idSelector = "boxnum";
                api.hideProgress();
                alert("连接超时，请耐心等待");
            }
        });
    }

    //自动保存
    function saveAuto() {
        //缺陷类型编码
        var qxTypeCode = $("#qxTypeCode").val();
        //缺陷类型名称
        var qxTypeName = $("#qxTypeName").val();
        //缺陷原因编码
        var mrlAttribute4 = $("#mrlAttribute4").val();
        //条码
        var tm = $("#tm").val();
        //条码唯一号ID
        var tmId = $("#tmId").val();
        //缺陷原因名称
        var mrlAttribute5 = $("#mrlAttribute5").val();
        //箱号
        var boxnum = $("#boxnum").val();


        //调入库位非空校验
        if (relWorkCellCode == "" || relWorkCellCode == null || relWorkCellCode == undefined) {
            api.toast({
                msg: '请选择/扫描 调入库位',
                duration: 3000
            });
            return;
        }

        //缺陷类型非空校验
        if (qxTypeCode == "" || qxTypeCode == null || qxTypeCode == undefined) {
            api.toast({
                msg: '缺陷类型不能为空',
                duration: 3000
            });
            return;
        }
        //缺陷原因非空校验
        if (mrlAttribute4 == "" || mrlAttribute4 == null || mrlAttribute4 == undefined) {
            api.toast({
                msg: '缺陷原因不能为空',
                duration: 3000
            });
            return;
        }


        //保存
        save();
    }

    //扫描之后条码解析
    function tmSplit1(sm) {
        var arr = sm.split(",");
        console.log("#mrlCode" + arr[1]);
        $("#tm").val(sm);
        if (arr[1] == null || arr[1] == undefined) {
            $("#mrlCode").val("");
        } else {
            $("#mrlCode").val(arr[1]);
        }
        if (arr[2] == null || arr[2] == undefined) {
            $("#qty").val("");
        } else {
            $("#qty").val(arr[2]);
        }
        if (arr[3] == null || arr[3] == undefined) {
            $("#lotCode").val("");
        } else {
            $("#lotCode").val(arr[3]);
        }
        if (arr[4] == null || arr[4] == undefined) {
            $("#tmId").val("");
        } else {
            $("#tmId").val(arr[4]);
        }
        if (arr[9] == null || arr[9] == undefined) {
            $("#boxnum").val("");
        } else {
            $("#boxnum").val(arr[9]);
        }
        backtype(sm);
        
        //自动保存
        //saveAuto();
        
    }
    function backtype(sm) {
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getStockBhg";
        var data = {
            values: {
                tm: sm, //条码
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //成功
                if (myobj.code == '0') {
                    //缺陷类型、原因
                    $("#qxTypeCode").val(myobj.qxTypeCode);
                    $("#qxTypeName").val(myobj.qxTypeCode +":"+myobj.qxTypeName);
                    $("#mrlAttribute4").val(myobj.mrlAttribute4);
                    $("#mrlAttribute5").val(myobj.mrlAttribute4+":"+myobj.mrlAttribute5);
                    $("#workCenterCode").val(myobj.workCenterCode+":"+myobj.workCenterName);
                    $("#workCellCode").val(myobj.workCellCode+":"+myobj.workCellName);
                    workCenterGid=myobj.workCenterId;
                    workCellGid=myobj.workCellId;

                    saveAuto();
                } else if (myobj.code == "1") {

                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            } 
        });
    }
    //扫描之后条码解析
    function tmSplit(sm) {
        $("#tm").val(sm);
        //直接解析
        if (scanRule == "old") {

            //本地解析
            localAnalyze(sm);

        } else {

            //后台解析
            postAnalyze(sm);
        }
    }
    //本地解析
    function localAnalyze(sm) {
        var arr = sm.split(",");
        if (arr[1] == null || arr[1] == undefined) {
            $("#mrlCode").val("");
        } else {
            $("#mrlCode").val(arr[1]);
        }
        if (arr[2] == null || arr[2] == undefined) {
            $("#qty").val("");
        } else {
            $("#qty").val(arr[2]);
        }
        if (arr[3] == null || arr[3] == undefined) {
            $("#lotCode").val("");
        } else {
            $("#lotCode").val(arr[3]);
        }
        if (arr[4] == null || arr[4] == undefined) {
            $("#tmID").val("");
        } else {
            $("#tmID").val(arr[4]);
        }
        if (arr[9] == null || arr[9] == undefined) {
            $("#boxnum").val("");
        } else {
            $("#boxnum").val(arr[9]);
        }


        saveAuto();
    }

    //后台解析条码
    function postAnalyze(sm) {
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/analysisBarCodeCommon";
        var data = {
            values: {
                tm: sm, //条码
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //成功
                if (myobj.code == '0') {

                    var map = myobj.data;
                    console.log("scanRulerrrrrrr:" + map["mrlCode"]);
                    $("#mrlCode").val(map["mrlCode"]);
                    $("#qty").val(map["qty"]);
                    $("#lotCode").val(map["lotCode"]);
                    $("#tmID").val(map["tmID"]);
                    $("#boxnum").val(map["boxnum"]);
                    //$("#tm").val(map["tm"]);
                    saveAuto();
                } else if (myobj.code == '1') {

                    $("#boxnum").val("");
                    $("#boxnum").select();
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            } else {
                alert(JSON.stringify(err));
            }
        });
    }

    //箱号监听回车事件
    $("#boxnum").on('keypress', function (e) { //#keyword为input文本框
        var keycode = e.keyCode;
        var tm = $(this).val();
        if (keycode == '13') {
            //$("#boxnum").select();
            if(tm != null && tm != "" && tm != undefined){
                $("#boxnum").blur();
                console.log("tm" + tm);
                var arr = tm.split(",");
                if (arr.length >= 9) {
                    //调用条码解析+保存事件
                    tmSplit(tm);
                }
            }

        }
    });

    //返回按钮
    function closeWin() {
        api.closeWin({});
    }
</script>

</html>